package com.hzdesk.media.koreabatchmatvector.logic.persenter;

import android.content.Context;

import com.hzdesk.media.koreabatchmatvector.adapter.MyDeskmediaFragmentAdapter;
import com.hzdesk.media.koreabatchmatvector.config.RxBusUtil;
import com.hzdesk.media.koreabatchmatvector.custom.NoScrollViewPager;
import com.hzdesk.media.koreabatchmatvector.logic.contract.DialogContract;
import com.hzdesk.media.koreabatchmatvector.utils.RxBus;
import com.orhanobut.logger.Logger;

import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2018/6/22.
 * 杭州席媒科技有限公司  Developers  刘传华  14
 * 佛祖镇楼 bug辟易
 */

public class DialogPersenter implements DialogContract.IDialogPersenter {
    private DialogContract.IDialogView mDialogView;

    public DialogPersenter(DialogContract.IDialogView tDialogView) {
        this.mDialogView = tDialogView;
    }

    public void initViewPagerDate(NoScrollViewPager mviewpager){
        mviewpager.setScroll(false);
        int viewpage_index = mDialogView.getViewpageIndex();
        mDialogView.viewpagerCurrentItemShow(viewpage_index);
    }

    public void initListen(){

        RxBus.getInstance().subscribe(Integer.class, new Consumer() {
            @Override
            public void accept(Object o) throws Exception {
                switch ((Integer) o){
                    case RxBusUtil.MOUSE_FRAGMENT_BACK:                                 // 鼠标页面的返回 20001
                        mDialogView.viewpagerCurrentItemShow(0);
                        break;
                    case RxBusUtil.CHANGE_MOUSE_LIST_FRAGMENR:                          // 显示鼠标列表页面 1
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_MOUSE_LIST_FRAGMENR);
                        break;
                    case RxBusUtil.CHANGE_VIDEO_LIST_FRAGMENT:                          //显示视频列表页面 2
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_VIDEO_LIST_FRAGMENT);
                        break;
                    case RxBusUtil.CHANGE_SELECT_FILE_FRAGMENT:                         // 显示选择文件页面 3
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_SELECT_FILE_FRAGMENT);
                        break;
                    case RxBusUtil.CHANGE_MOUSR_SET_FRAGMENT:                           // 显示鼠标设置页面 4
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_MOUSR_SET_FRAGMENT);
                        break;
                    case RxBusUtil.CHANGE_BOUND_CLOUD_SERVICE_FRAGMENT:                 // 显示绑定云服务页面 5
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_BOUND_CLOUD_SERVICE_FRAGMENT);
                        break;
                    case RxBusUtil.BOUND_CLOUD_SERVICE_FRAGMENT_BACK:                   // 绑定云服务的返回  50001
                        mDialogView.viewpagerCurrentItemShow(0);
                        break;
                    case RxBusUtil.CHANGE_ABOUT_FRAGMENT:                               // 显示关于可立批页面 6
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_ABOUT_FRAGMENT);
                        break;
                    case RxBusUtil.CHANGE_CLOUD_LIST_FRAGMENT:                          //显示云端列表 7
                        mDialogView.viewpagerCurrentItemShow(RxBusUtil.CHANGE_CLOUD_LIST_FRAGMENT);
                        break;
                    case RxBusUtil.SET_FRAGMENT_BACK:                                   //  设置页面的返回 10001
                        mDialogView.finshPager();
                        break;
                }
            }
        });
    }

}
